<?php
/**
 * @author haohan
 * @since  2009-11-25
 * @登录类
 */
 //require('IP/ip.php');
 //session_start();
 class Userlogin
 {
   private $tpm=null;
   private $tpl=null;
   function __construct(&$tpm,&$tpl)
	 {	   
       $this->tpm=$tpm;
	   $this->tpl=$tpl;
     }
   function user($sql)
	 {
	    
       $query = $this->tpm->query($sql);
	   $num   = $this->tpm->num_rows($query);
	   $rs    = $this->tpm->fetch_array($query); 
	   if($num==1)
		 {
		   $_SESSION['LoginId'] = $rs['id'];
		 /*  $ip=get_ip();
           $myobj=new ipLocation();
           $address=$myobj->getaddress($ip);
           $myobj=NULL;
		   $ip=$address['ip'];
		   $sql="update admin_user set last_ip='".$ip."',last_login='".date('Y-m-d h:i:s')."' where id='".$rs['id']."'";
		   $query=$this->tpm->query($sql);*/
		   refreshto($this->tpl,'index.php','Login successfully!');
	     }
	   else
           refreshto($this->tpl,'login.php','Login unsuccessfully！');
     }
 }
?>